import AABB from "./AABB";
import QuadTreeNode from "./QuadTreeNode";

// QuadTree
export default class QuadTree {

  // 最大深度
  public static sNumMaxDepth: number = null;

  // 单个节点中允许存储的最大对象树
  public static sNumMaxObject: number = null;

  // 根节点
  public mNodRoot: QuadTreeNode = null;

  constructor(pRect: cc.Rect, pNumMaxDepth: number = 3, pNumMaxObject: number = 5) {
    QuadTree.sNumMaxDepth = pNumMaxDepth;
    QuadTree.sNumMaxObject = pNumMaxObject;
    this.mNodRoot = new QuadTreeNode(pRect, null, 0);
  }

  // 插入节点
  public insert(pObject: AABB) {
    this.mNodRoot.insert(pObject);
  }

  // 获取节点
  public retrieve(pRect: cc.Rect): AABB[] {
    return this.mNodRoot.retrieve(pRect);
  }
}



